package com.study.paymentdemo.controller;

import com.study.paymentdemo.service.ProductService;
import com.study.paymentdemo.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author lhl
 * @date 2024/12/4 11:18
 */
@CrossOrigin //开放前端跨域问题
@Api(tags = "商品管理")
@RestController
@RequestMapping("/api/product")
public class ProductController {

    @Resource
    private ProductService productService;

    @ApiOperation("测试接口")
    @GetMapping("/test")
    public R test(){
        return R.ok().data("message","Hello").data("time",new Date());
    }

    @GetMapping("/productList")
    public R productList(){
        return R.ok().data("productList",productService.list());
    }
}
